package com.cy.pj.brand.controller;

import com.cy.pj.brand.pojo.Brand;
import com.cy.pj.brand.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class BrandController {
    @Autowired
    private BrandService brandService;

    @RequestMapping({"/brand/doFindBrands/{name}", "/brand/doFindBrands"})
    public String FindBrands(@PathVariable(required = false) String name, Model model) {
        List<Brand> brands = brandService.findBrands(name);
        model.addAttribute("list", brands);
        return "brand/brand";
    }

}
